package com.lukebang.controller;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lukebang.service.IndentService;
@Controller
@RequestMapping("/indent")
public class IndentController {
	@Resource
	private IndentService indentService;
	
	/**
	 * 功能：取消订单
	 * @param request
	 * @param mesureIndentId
	 * @return
	 */
	@RequestMapping("/quitIndent")
	@ResponseBody
	public Map<String,Object> quitInstallIndent(HttpServletRequest request,HttpSession session,Integer indentId,Integer merchantId,Integer type,Double subMoney){
		return indentService.quitIndent(request, session, type, indentId,merchantId,subMoney);
	}
	
	@RequestMapping("/showSubMoney")
	@ResponseBody
	public Double showSubMoney(HttpServletRequest request,HttpSession session,Integer indentId){
		return indentService.getSubMoney(indentId);
	}
	
	@RequestMapping("/aliPayIndent")
	public String aliPayIndent(HttpServletRequest request, Integer indentID, Double addPrice, Integer relievedBao,
			Integer crampetNumber, Integer fourClawNumber, Integer motorNumber,Double totalPrice, HttpSession session) {
		try {
			System.out.println("订单ID是："+ indentID+",addPrice="+addPrice+",relievedBao="+ relievedBao+",crampetNumber="+crampetNumber+",fourClawNumber="+fourClawNumber+",motorNumber="+motorNumber);
			indentService.modifyForPayIndent(request, indentID, addPrice, relievedBao, crampetNumber,
					fourClawNumber, motorNumber, totalPrice,session);
			return "forward:/cms/alipay/alipayapi.jsp";
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
